package com.naver.hdfs;

import java.io.DataOutputStream;
import java.io.IOException;

import model.Board;

import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

public class HDFSBoardDAO {
	
	public void makeDirectory(FileSystem fs, Path path) throws IOException {
		if(!fs.exists(path)) {
			fs.mkdirs(path);
		}
	}
	
	public void delete(FileSystem fs, Path path) throws IOException {
		if (fs.exists(path)) {
			fs.delete(path, true);
		}
	}
	
	public void write(Board board, DataOutputStream out) throws IOException {
		out.write(String.valueOf(board.getArticleNo()).getBytes());
		out.write(" ".getBytes());
		out.write(board.getTitle().getBytes());
		out.write(" ".getBytes());
		out.write(board.getContent().getBytes());
	}
}
